﻿using UnityEngine;
using System.Collections;
using System.Threading;

public abstract class AniEffectC : MonoBehaviour, AniEffect {

	public static GameObject effectObject(Object effect, GameObject self, CallBack complete) {
		GameObject effectObject = Instantiate(effect) as GameObject;
		effectObject.transform.parent = self.transform;
		if(effect is GameObject) {
			Transform effectTrans = ((GameObject) effect).transform;
			effectObject.transform.localPosition = effectTrans.localPosition;
			effectObject.transform.localScale = effectTrans.localScale;
			effectObject.transform.localRotation = effectTrans.localRotation;

		} else {
			effectObject.transform.localPosition = Vector3.zero;
		}

		effectObject.SetActive(true);
		if(complete != null) {
			AniBase aniBase = effectObject.GetComponentInChildren<AniBase>();
			if(aniBase == null) {
				complete();

			} else {
				aniBase.playCallBack(complete);
			}
		}

		return effectObject;
	}

	public abstract void play (OReportDetail detail, CallBack complete);
}
